package fr.matspider.vampireinvader.entities;

//import org.newdawn.slick.Animation;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.SpriteSheet;

public class Player {
	
	private float x, y;
	private SpriteSheet playerSprite;
	private Image current;
	private float playerSpeed = 1.0f;
	//private Animation playerAnimation;
	
	
	public Player(float x, float y){
		this.x = x; this.y = y;
	}
	
	public void render(GameContainer gc, Graphics g) throws SlickException {
		playerSprite = new SpriteSheet("res/player.png", 92, 132);
		current = playerSprite.getSprite(0, 0);
		g.drawImage(current, this.x, this.y);
	}

	public void init(GameContainer gc) throws SlickException {
		
	}

	public void update(GameContainer gc, int delta) throws SlickException {
		if(gc.getInput().isKeyDown(Input.KEY_RIGHT)){
			this.x += playerSpeed;
			/*playerAnimation = new Animation(new Image[]{new SpriteSheet("res/player.png", 92, 132).getSprite(0, 3), new SpriteSheet("res/player.png", 92, 132).getSprite(1, 3)}, 250);
			playerAnimation.draw(this.x, this.y);
			playerAnimation.start();*/
		} else if(gc.getInput().isKeyDown(Input.KEY_LEFT)){
			this.x -= playerSpeed;
		} else if(gc.getInput().isKeyDown(Input.KEY_UP)){
			this.y += playerSpeed;
		} else if(gc.getInput().isKeyDown(Input.KEY_DOWN)){
			this.y -= playerSpeed;
		}
		current.draw(this.x, this.y);
	}

}
